<?php
/* @var $this PhancongController */
/* @var $model Phancong */
/* @var $form CActiveForm */
?>

<div class="wide form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
)); ?>
<table class="tableSearch" style="width:100%">
	<div class='row'>
		<td class="tbSkhoaPT"><?php echo $form->labelEx($model,'chuongtrinh.madonvi'); ?></td>
		<td style="width:150px;"><?php 
		$connection=Yii::app()->db;   // assuming you have configured a "db" connection
		$command=$connection->createCommand()
		->select('madonvi,tendonvi,thuocSGU')
		->from('donvicongtac')
		->query();
		$dvphutrach= array();
		foreach($command as $row)
		{
			if($row['thuocSGU']==1)
			{
			$dvphutrach[$row['madonvi']]=$row['tendonvi'];}
		}
		echo $form->dropDownList($model,'chuongtrinh_khoaphutrach_search',$dvphutrach,array('empty'=>'')); ?></td>
		<td style="width:10px;"></td>
		<td style="width:100px;"><?php echo $form->labelEx($model,'chuongtrinh.madonviday'); ?></td>
		<td style="width:250px;"><?php 
		$commandDV=$connection->createCommand()
		->select('madonvi,tendonvi,laKhoa')
		->from('donvicongtac')
		->query();
		$khoa= array();
		foreach($commandDV as $rowDV)
		{
			//array_push($ngach,$row);
			if($rowDV['laKhoa']==1)
			{
			$khoa[$rowDV['madonvi']]=$rowDV['tendonvi'];}
		}
		echo $form->dropDownList($model,'chuongtrinh_khoaday_search',$khoa,array('empty'=>'')); ?></td>
	</div>

	<div class="row">
	<tr>
		<td style='width:15%'><?php echo $form->labelEx($model,'nhomlop.namhoc'); ?></td>
		<td><?php
			$now=getdate();
			$year=array();
			for($i=$now['year']-7;$i<$now['year'];$i++)
				$year[$i]=$i.' - '.($i+1);
		echo $form->dropDownList($model,'nhomlop_namhoc_search',$year,array('empty'=>'')); ?></td>
		<td></td>
		<td><?php echo $form->label($model,'nhomlop.hocki'); ?></td>
		<td><?php echo $form->dropDownList($model,'nhomlop_hocki_search',array(1=>1,2=>2),array('empty'=>'')); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->label($model,'nhomlop.makhoilop'); ?></td>
		<td><?php $connection=Yii::app()->db;   // assuming you have configured a "db" connection
		$command=$connection->createCommand()
		->select('makhoilop')
		->from('thongtinsv')
		->query();
		$khoilop= array();
		foreach($command as $row)
		{
			//array_push($ngach,$row);
			$khoilop[$row['makhoilop']]=$row['makhoilop'];
		}
		echo $form->dropDownList($model,'nhomlop_makhoilop_search',$khoilop,array('empty'=>'')); ?></td>
		<td></td>
		<td><?php echo $form->label($model,'monhoc.mamh'); ?></td>
		<td><?php 
			$connection=Yii::app()->db;   // assuming you have configured a "db" connection
			$command=$connection->createCommand()
			->select('mamh,tenmh')
			->from('monhoc')
			//->where(array('and','username="'.$this->username.'"','level>0'))
			->query();
			$hocphan= array();
			foreach($command as $row)
			{
				//array_push($ngach,$row);
				$hocphan[$row['mamh']]=$row['tenmh'];
			}
			$this->widget('ext.widgets.select2.XSelect2', array(
							'model'=>$model,
							'attribute'=>'monhoc_mamh_search',
							'data'=>$hocphan,
							'options'=>array(
								'maximumSelectionSize'=>10,
							),
							'htmlOptions'=>array(
								'style'=>'width:15.5em',
								'multiple'=>'true'//,
							   // 'class'=>'countries-select'
							),
							'events'=>array(
								'selected'=>"js:function (element) {
									$('[data-khoa='+element.val+']').hide();
								}",
								'removed'=>"js:function (element) {
									$('[data-khoa='+element.val+']').show();
								}"
							),
						)); ?></td>
	</tr>
	</div>

	<div class="row buttons">
	<tr>
		<td></td>
		<td><?php echo CHtml::submitButton('Tìm kiếm',array('id'=>'btnTim')); ?></td>
	</tr>
	</div>
</table>
<?php $this->endWidget(); ?>

</div><!-- search-form -->